package com.leige.webconfig.swagger2;
import static com.google.common.base.Predicates.and;
import static springfox.documentation.builders.PathSelectors.regex;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
@EnableWebMvc
@EnableSwagger2
@PropertySource("classpath:conf/swagger.properties")
@Import(SwaggerUiConfiguration.class)
public class SwaggerConfig {
	
    private ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfo(
        "App Name",
        "文档",
        "1.0.0",
        "",
        "",
        "",
        "" );
        return apiInfo;
    }
    @Bean
    public Docket customImplementation() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("1.app")
                .pathMapping("/")//最终调用接口后会和paths拼接在一起
                .select()
                .paths(and(regex("/app/.*")))//过滤的接口
                .build()
                .apiInfo(apiInfo());
    }

}